//---------------------------------------------------------------------------

#ifndef SimCompH
#define SimCompH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <ComCtrls.hpp>
#include <ExtCtrls.hpp>
//---------------------------------------------------------------------------
#define MOTION_QUEUE_SIZE 128
#define ADULT_SIZED		0
#define KID_SIZED			1


// C -> Computer / Strategy
// B -> Control Board (Arduino / STM32)
typedef enum
{
	C2B_HEAD1 				= 0,
	C2B_MOTION_MODE		= 1,
	C2B_CONT_DIS_L		= 2,
	C2B_CONT_DIS_H		= 3,
	C2B_CONT_ANGLE_L	= 4,
	C2B_CONT_ANGLE_H	= 5,
	C2B_HEAD_MODE			= 6,
	C2B_MOTOR_0_L			= 7,
	C2B_MOTOR_0_H			= 8,
	C2B_MOTOR_1_L			= 9,
	C2B_MOTOR_1_H			= 10,
	C2B_CHECKSUM			= 11,
	C2B_LENGTH				= 12
} C2BPacketDef;

typedef enum
{
	B2C_ADULT_HEAD1					= 0,
	B2C_ADULT_HEAD2					= 1,
	B2C_ADULT_DIP						= 2,
	B2C_ADULT_HEAD_PITCH_L	= 3,
	B2C_ADULT_HEAD_PITCH_H	= 4,
	B2C_ADULT_HEAD_YAW_L 		= 5,
	B2C_ADULT_HEAD_YAW_H		= 6,
	B2C_ADULT_WAIST_ROLL_L	= 7,
	B2C_ADULT_WAIST_ROLL_H	= 8,
	B2C_ADULT_WAIST_PITCH_L	= 9,
	B2C_ADULT_WAIST_PITCH_H	= 10,
	B2C_ADULT_WAIST_YAW_L		= 11,
	B2C_ADULT_WAIST_YAW_H		= 12,
	B2C_ADULT_MOTION_DONE		= 13,
	B2C_ADULT_AZIMUTH_L			= 14,
	B2C_ADULT_AZIMUTH_H			= 15,
	B2C_ADULT_CHECKSUM			= 16,
	B2C_ADULT_LENGTH				= 17
} B2C_ADULTPackerDef;

typedef enum
{
	B2C_KID_HEAD1							= 0,
	B2C_KID_HEAD2							= 1,
	B2C_KID_DIP								= 2,
	B2C_KID_HEAD_PITCH_L			= 3,
	B2C_KID_HEAD_PITCH_H			= 4,
	B2C_KID_HEAD_YAW_L 				= 5,
	B2C_KID_HEAD_YAW_H				= 6,
	B2C_KID_MOTION_DONE				= 7,
	B2C_KID_HEADSEARCH_COUNT	= 8,
	B2C_KID_AZIMUTH_L					= 9,
	B2C_KID_AZIMUTH_H					= 10,
	B2C_KID_DONE_ANGLE				= 11,
	B2C_KID_CHECKSUM					= 12,
	B2C_KID_LENGTH						= 13
} B2C_KIDPackerDef;

class TFormSimComp : public TForm
{
__published:	// IDE-managed Components
	TGroupBox *GroupBoxRecInfo;
	TLabel *Label1;
	TLabel *Label2;
	TLabel *Label3;
	TLabel *Label4;
	TLabel *Label5;
	TLabel *Label6;
	TLabel *Label7;
	TLabel *Label8;
	TLabel *Label_DIP;
	TLabel *Label_HP;
	TLabel *Label_HY;
	TLabel *Label_WR;
	TLabel *Label_WP;
	TLabel *Label_WY;
	TLabel *Label_MD;
	TLabel *Label_Azimuth;
	TGroupBox *GroupBoxSendInfo;
	TLabel *Label9;
	TLabel *Label10;
	TLabel *Label11;
	TLabel *Label12;
	TLabel *Label13;
	TLabel *Label14;
	TEdit *Edit_MD;
	TEdit *Edit_CD;
	TEdit *Edit_CA;
	TEdit *Edit_HM;
	TEdit *Edit_HP;
	TEdit *Edit_HY;
	TButton *ButtonSend;
	TScrollBar *ScrollBar_HY;
	TScrollBar *ScrollBar_HP;
	TCheckBox *CheckBoxSend;
	TPageControl *PageControlMotion;
	TTabSheet *TabSheet_MotionQueue;
	TGroupBox *GroupBox1;
	TButton *Button_WalkF;
	TButton *Button_WalkFF;
	TButton *Button_ShiftRR;
	TButton *Button_WalkBB;
	TButton *Button_WalkB;
	TButton *Button_ShiftR;
	TButton *Button_ShiftLL;
	TButton *Button_ShiftL;
	TButton *Button_Pick;
	TButton *Button_Throw;
	TGroupBox *GroupBox2;
	TButton *Button_KickL;
	TButton *Button_KickLL;
	TGroupBox *GroupBox3;
	TButton *Button_KickRR;
	TButton *Button_KickR;
	TGroupBox *GroupBox4;
	TButton *Button_TurnballRR;
	TButton *Button_TurnballR;
	TGroupBox *GroupBox5;
	TButton *Button_TurnballL;
	TButton *Button_TurnballLL;
	TGroupBox *GroupBox6;
	TButton *Button_TurnL;
	TButton *Button_TurnLL;
	TGroupBox *GroupBox7;
	TButton *Button_TurnRR;
	TButton *Button_TurnR;
	TButton *Button_Stop;
	TButton *Button_LiftL;
	TButton *Button_LiftH;
	TGroupBox *GroupBox10;
	TLabel *Label15;
	TEdit *Edit_MCD;
	TLabel *Label16;
	TEdit *Edit_MCA;
	TRadioGroup *RadioGroup_Motiontype;
	TButton *Button_Whatever;
	TEdit *Edit_MotionWhatever;
	TButton *Button_Waist;
	TButton *Button_SidekickL;
	TButton *Button_SidekickR;
	TMemo *MemoMotion;
	TLabel *Label17;
	TEdit *Edit_Mcount;
	TButton *Button_MClear;
	TButton *Button_Mshow;
	TTabSheet *TabSheet1;
	TButton *Button_RunMotion;
	TButton *Button_StopMotion;
	TLabel *Label18;
	TEdit *Edit_RunDIP;
	TLabel *Label19;
	TLabel *Label20;
	TLabel *Label_MHead;
	TLabel *Label_MTail;
	TLabel *Label_MNow;
	TLabel *Label21;
	TRadioGroup *RadioGroupRobotType;
	TButton *Button_Default;
	void __fastcall Edit_HPKeyPress(TObject *Sender, wchar_t &Key);
	void __fastcall Edit_HYKeyPress(TObject *Sender, wchar_t &Key);
	void __fastcall FormCreate(TObject *Sender);
	void __fastcall ScrollBar_HPChange(TObject *Sender);
	void __fastcall ScrollBar_HYChange(TObject *Sender);
	void __fastcall ButtonSendClick(TObject *Sender);
	void __fastcall CheckBoxSendClick(TObject *Sender);
	void __fastcall MotionButtonClick(TObject *Sender);
	void __fastcall Button_MClearClick(TObject *Sender);
	void __fastcall Button_MshowClick(TObject *Sender);
	void __fastcall MemoMotionDblClick(TObject *Sender);
	void __fastcall MemoMotionMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift,
          int X, int Y);
	void __fastcall Button_RunMotionClick(TObject *Sender);
	void __fastcall Button_StopMotionClick(TObject *Sender);
	void __fastcall Button_DefaultClick(TObject *Sender);
	void __fastcall Button_MshowMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift,
          int X, int Y);
private:	// User declarations
public:		// User declarations
	__fastcall TFormSimComp(TComponent* Owner);
	bool B2C_DataCheck(unsigned char* buf, int length_buf);
	void UpdateRecInfo(int type);
	void InitSendInfo(void);
	int RunMotionQueue(void);
	void Send_C2B_Data(void);
};
//---------------------------------------------------------------------------
extern PACKAGE TFormSimComp *FormSimComp;
//---------------------------------------------------------------------------
#endif
